package com.jz.community.basecomm.loaction;


import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.basecomm.bean.RegionsBean;
import com.jz.community.basecommunity.R;

import java.util.List;


public class CityAdapter extends BaseQuickAdapter<RegionsBean.EmbeddedBean.ContentBean, BaseViewHolder> {


    public CityAdapter(@LayoutRes int layoutResId, @Nullable List<RegionsBean.EmbeddedBean.ContentBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RegionsBean.EmbeddedBean.ContentBean entity) {
        TextView textView = helper.getView(R.id.city_name);
        textView.setText(entity.getName());
    }


    public int getLetterPosition(String letter) {
        for (int i = 0; i < getData().size(); i++) {
            if (getData().get(i).getFirstCharacter().equals(letter)) {
                return i;
            }
        }
        return -1;
    }

    public int getCityPosition(String cityName) {
        for (int i = 0; i < getData().size(); i++) {
            if (getData().get(i).getName().contains(cityName)) {
                return i;
            }
        }
        return -1;
    }
}
